package com.pinyoumei.app.view.dialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;

import com.pinyoumei.app.R;

/**
 * 图片选择弹框
 */
public class PointCheckDialog extends Dialog{
    private Context context;
    private int layoutResID;//布局文件id
    private int[] listenedItems;//存放控件id的数组
    private RelativeLayout relative_photo,relative_native,relative_cancle;

    public PointCheckDialog(Context context){
        super(context);
        this.context = context;
    }

    public PointCheckDialog(Context context, boolean cancelable, OnCancelListener cancelListener){
        super(context,cancelable,cancelListener);
    }
    public PointCheckDialog(Context context, int layoutResID ){
        super(context, R.style.dialogStyle);//这个决定dialog的样式
        this.context = context;
        this.layoutResID = layoutResID;

    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Window window = getWindow();//获取一个窗口
        window.setGravity(Gravity.BOTTOM);//设置窗口的位置
        window.setWindowAnimations(R.style.bottom_menu_animation);//设置窗口进入时的动画特效
        WindowManager.LayoutParams layoutParams = window.getAttributes();//获取窗口的属性赋值给layoutParams
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        window.setAttributes(layoutParams);//设置窗口的属性
        setCanceledOnTouchOutside(true);
        setContentView(layoutResID);

    }

    @Override
    public void show() {
        super.show();
        /**
         * 设置宽度全屏，要设置在show的后面
         */
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.gravity=Gravity.BOTTOM;
        layoutParams.width= WindowManager.LayoutParams.MATCH_PARENT;
        layoutParams.height= WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().getDecorView().setPadding(0, 0, 0, 0);
        getWindow().setAttributes(layoutParams);
    }

}
